package org.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * <p>Project: day12 - FileUtil</p>
 * <p>Powered by aix On 2023-07-24 13:01:20</p>
 * <p>描述：<p>
 *
 * @author aix [1305228917@qq.com]
 * @version 1.0
 * @since 17
 */
public class FileUtil {

    public static void copyFile(File file, String Out) {
        File Output = new File(Out);
        if (!Output.exists()) {
            Output.mkdirs();
        }
        try (var fis = new FileInputStream(file)) {
            byte[] bytes = new byte[10240];
            int len = 0;
            String filename = Out + "\\" + file.getName();
            try (var fos = new FileOutputStream(filename)) {
                while ((len = fis.read(bytes)) != -1) {
                    fos.write(bytes, 0, len);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
